/**********************************************************************************************************************
 * @file    weak.c
 * @author  Queclink Hubert.Lee
 * @date    2016-12-22
 * @brief   ��ʹ�õ�����ϵͳ��صĽӿڶ���.
 *
 * Copyright (C) 2016 Queclink Wireless Solutions (ShenZhen) Co., Ltd. All Rights Reserved.
 *
 * @attention
 *
 *********************************************************************************************************************/

#ifndef HDL_FOR_FreeRTOS

/* includes ---------------------------------------------------------------------------------------------------------*/
#include <stddef.h>
#include <stdlib.h>
#include <public/compiler.h>

#include "FreeRTOS.h"
#include "cmsis_os.h"

void *lib_domalloc(size_t size, const char *file, int line, const char *func)
{
    return pvPortMalloc(size);
}

void lib_dofree(void *ptr, const char *file, int line, const char *func)
{
    vPortFree(ptr);
}

#include "bsp_wdt.h"
void lib_watchdog_feed(void)
{
    bsp_wdt_feed();
}

__WEAK__ int lib_semaphore_create(void)
{
    return 0;
}
__WEAK__ int lib_semaphore_obtain(int id)
{
    return 0;
}
__WEAK__ int lib_semaphore_release(int id)
{
    return 0;
}

__WEAK__ int lib_semaphore_delete(int id)
{
    return 0;
}

__WEAK__ int lib_semaphore_obtain_isr(int id)
{
    return 0;
}
__WEAK__ int lib_semaphore_release_isr(int id)
{
    return 0;
}

__WEAK__ void lib_delay_ms(unsigned int ms)
{
    unsigned int unit = 4740;				/* ��������48MHZ�²�� */
    volatile unsigned int i;
    while (ms--) {
        for (i = 0; i < unit; i++) ;
    }
}

__WEAK__ void lib_delay_us(unsigned int us)
{
    volatile unsigned int i = 7 * us;		/* ��������48MHZ�²�� */
    while (i--);
}

#endif /* HDL_FOR_FreeRTOS */